package hot100.logos71To80;

/**
 * @author logos
 * date 2025/7/17 19:28
 * @version v1.0
 * @Package hot100.logos71To80
 */
public class logos78 {

    /**
     * 78. 跳跃游戏
     * https://leetcode.cn/problems/jump-game/description/?envType=study-plan-v2&envId=top-100-liked
     */

    class Solution {
        public boolean canJump(int[] nums) {
            int n = nums.length;
            if (n == 1) {
                return true;
            }
            int cover = 0;
            for (int i = 0; i <= cover; i++) {
                if ((i + nums[i]) > cover) {
                    cover = i + nums[i];
                }
                if (cover >= n - 1) {
                    return true;
                }
            }
            return false;
        }
    }
}
